package org.tony.algorithms.sort;

public class InsertSort
{

	public static void insertSort(int[] src)
	{
		int length = src.length;
		for (int i = 0; i < length; i++)
		{

			int current = src[i];
			int j = i;
			while (j > 0 && src[j - 1] > current)
			{
				src[j] = src[j - 1];
				j--;
			}
			src[j] = current;

		}
	}

	public static void main(String[] args)
	{
		int[] a = { 9, 10, 8, 8, 7, 6, 5, 4, 3, 2, 1 };
		insertSort(a);
		for (int i : a)
		{
			System.out.print(i + " ");
		}
	}
}
